home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / upc12bs1.zip / LIB / lib.h < prev    next >
C/C++ Source or Header  |  1993-09-29  |  12KB  |  314 lines

  1. /*--------------------------------------------------------------------*/
  2. /*       l i b . h                                                    */
  3. /*--------------------------------------------------------------------*/
  4.  
  5. /*--------------------------------------------------------------------*/
  6. /*       Changes Copyright (c) 1989-1993 by Kendra Electronic         */
  7. /*       Wonderworks.                                                 */
  8. /*                                                                    */
  9. /*       All rights reserved except those explicitly granted by       */
  10. /*       the UUPC/extended license agreement.                         */
  11. /*--------------------------------------------------------------------*/
  12.  
  13. /*--------------------------------------------------------------------*/
  14. /*                          RCS Information                           */
  15. /*--------------------------------------------------------------------*/
  16.  
  17. /*
  18.  *    $Id: lib.h 1.13 1993/09/29 04:56:11 ahd Exp $
  19.  *
  20.  *    Revision history:
  21.  *    $Log: lib.h $
  22.  *     Revision 1.13  1993/09/29  04:56:11  ahd
  23.  *     Revise B_KEWSHORT to B_SHORT
  24.  *
  25.  *     Revision 1.12  1993/09/20  04:51:31  ahd
  26.  *     1.12OS/2 2.x support
  27.  *
  28.  *     Revision 1.11  1993/08/08  17:39:55  ahd
  29.  *     Define denormalize() macro
  30.  *
  31.  *     Revision 1.10  1993/07/22  23:26:19  ahd
  32.  *     First pass of changes for Robert Denny's Windows 3.1 support
  33.  *
  34.  *     Revision 1.9  1993/07/19  02:53:32  ahd
  35.  *     Update copyright year'
  36.  *
  37.  *     Revision 1.8  1993/06/13  14:12:29  ahd
  38.  *     Changes per Mike McLagan for outbound batched news support
  39.  *
  40.  *     Revision 1.7  1993/05/30  15:27:22  ahd
  41.  *     Drop PASSWD, SYSTEMS definitions
  42.  *
  43.  *     Revision 1.6  1993/05/30  00:11:03  ahd
  44.  *     Drop free() macro
  45.  *     Drop hardcoded PASSWD and SYSTEM file names
  46.  *     Add RCSID macro
  47.  *
  48.  *     Revision 1.5  1993/04/04  21:51:00  ahd
  49.  *     Update copyright
  50.  *
  51.  *     Revision 1.4  1993/03/06  23:09:50  ahd
  52.  *     Break variable names out of master lib.h
  53.  *
  54.  *     Revision 1.3  1992/12/01  04:39:34  ahd
  55.  *     Add SpeedOverMemory
  56.  *
  57.  * Revision 1.2  1992/11/22  21:31:22  ahd
  58.  * Allow strpool() to allocate memory for const strings
  59.  *
  60.  * Revision 1.1  1992/11/16  05:00:26  ahd
  61.  * Initial revision
  62.  *
  63.  */
  64.  
  65. #ifndef __LIB
  66. #define __LIB
  67.  
  68. #if defined(WIN32) || defined(__OS2__)
  69. #define BIT32ENV
  70. #endif
  71.  
  72. #include <confvars.h>
  73.  
  74. /*--------------------------------------------------------------------*/
  75. /*     Environment variables set by UUXQT before invoking modules     */
  76. /*--------------------------------------------------------------------*/
  77.  
  78. #define UU_USER "UU_USER"
  79. #define UU_MACHINE "UU_MACHINE"
  80. #define LOGNAME "LOGNAME"
  81. #define RMAIL   "rmail"
  82. #define RNEWS   "rnews"
  83.  
  84. /*--------------------------------------------------------------------*/
  85. /*                   Global configuration variables                   */
  86. /*--------------------------------------------------------------------*/
  87.  
  88. #define SYSRCSYM "UUPCSYSRC"
  89. #define USRRCSYM  "UUPCUSRRC"
  90. #define SYSDEBUG  "UUPCDEBUG"    /* Initialize debug level ahd       */
  91.  
  92. /*--------------------------------------------------------------------*/
  93. /*                 Macro for recording when UUPC dies                 */
  94. /*--------------------------------------------------------------------*/
  95.  
  96. #define panic()  bugout( __LINE__, cfnptr)
  97.  
  98. /*--------------------------------------------------------------------*/
  99. /*                 Macro for generic error messages from DOS          */
  100. /*--------------------------------------------------------------------*/
  101.  
  102. #define printerr( x )  prterror( __LINE__, cfnptr, x)
  103.  
  104. /*--------------------------------------------------------------------*/
  105. /*                  Convert hours/minutes to seconds                  */
  106. /*--------------------------------------------------------------------*/
  107.  
  108. #define hhmm2sec(HHMM)    ((time_t)(((HHMM / 100) * 60L) + \
  109.                            (time_t)(HHMM % 100)) * 60L)
  110.  
  111. #define RCSID static const char UUFAR rcsid[] =
  112.  
  113. /*--------------------------------------------------------------------*/
  114. /*                     Configuration file defines                     */
  115. /*--------------------------------------------------------------------*/
  116.  
  117. #define B_REQUIRED 0x00000001L /* Line must appear in configuration   */
  118. #define B_FOUND    0x00000002L /* We found the token                  */
  119.  
  120. #define B_GLOBAL   0x00000004L /* Must not appear in PERSONAL.RC      */
  121. #define B_LOCAL    0x00000008L /* The opposite of B_GLOBAL, sort of   */
  122.  
  123. #define B_MTA      0x00000010L /* Used by Mail Delivery (RMAIL)       */
  124. #define B_MUA      0x00000020L /* Used by Mail User Agent (MAIL)      */
  125. #define B_MUSH     0x00000040L /* Used by MUSH - Not used by UUPC     */
  126. #define B_NEWS     0x00000080L /* Used by NEWS software               */
  127. #define B_UUCICO   0x00000100L /* Used by transport program UUCICO    */
  128. #define B_UUCP     0x00000200L /* Used by UUCP command                */
  129. #define B_UUPOLL   0x00000400L /* UUPOLL program                      */
  130. #define B_UUSTAT   0x00000800L /* UUSTAT, UUSUB, UUNAME programs      */
  131. #define B_UUXQT    0x00001000L /* Used by queue processor UUXQT       */
  132. #define B_INSTALL  0x00002000L /* Used by install program only        */
  133. #define B_BATCH    0x00004000L // Used by news batching program - GMM
  134. #define B_MAIL     (B_MUA | B_MTA | B_MUSH)
  135. #define B_SPOOL    (B_MTA | B_NEWS | B_UUCICO | B_UUXQT | B_UUCP | B_UUSTAT)
  136. #define B_ALL      (B_MAIL|B_SPOOL|B_NEWS|B_UUPOLL|B_UUSTAT|B_BATCH)
  137.  
  138. #define B_SHORT    0x00010000L /* Pointer is to short int, not string */
  139. #define B_TOKEN    0x00020000L /* Pointer is one word, ignore blanks  */
  140. #define B_BOOLEAN  0x00040000L /* Pointer is to boolean keywords      */
  141. #define B_LIST     0x00080000L /* Pointer to array of char pointers   */
  142. #define B_CLIST    0x00100000L /* Pointer to array of char pointers,
  143.                                   input is separated by colons, not
  144.                                   spaces                              */
  145. #define B_STRING   0x00200000L /* String value (same as original UUPC
  146.                                   configuration processor             */
  147. #define B_NORMAL   0x00400000L /* Normalize backslashes to slashes in
  148.                                   in this variable                    */
  149. #define B_OBSOLETE 0x00800000L /* Option is obsolete, should be
  150.                                   deleted                             */
  151. #define B_MALLOC   0x01000000L  /* Use malloc(), not newstr()         */
  152. #define B_LONG     0x02000000L  /* Pointer is to long, not string     */
  153. #define B_PATH     (B_TOKEN | B_NORMAL)
  154.                                /* DOS Path name                       */
  155.  
  156. /*--------------------------------------------------------------------*/
  157. /*                     General defines and macros                     */
  158. /*--------------------------------------------------------------------*/
  159.  
  160. #define  MESSAGESEP "\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\n"
  161.  
  162. #define DCSTATUS    "hostatus"
  163. #define PATHS       "hostpath"
  164. #define PERMISSIONS "permissn"
  165. #define SYSLOG      "syslog"
  166. #define ACTIVE      "active"
  167.  
  168. #define WHITESPACE " \t\n\r"
  169.  
  170. /*--------------------------------------------------------------------*/
  171. /*    Equality macros                                                 */
  172. /*--------------------------------------------------------------------*/
  173.  
  174. #define equal(a,b)               (!strcmp(a,b))
  175. #define equali(a,b)              (!stricmp(a,b))                     /*ahd */
  176. #define equalni(a,b,n)           (!strnicmp(a,b,n))                  /*ahd */
  177. #define equaln(a,b,n)            (!strncmp(a,b,n))
  178.  
  179. #ifndef __FILE__
  180. #error __FILE__ must be defined!!!
  181. #endif
  182.  
  183. #define currentfile()            static char *cfnptr = __FILE__
  184. #define checkref(a)              (checkptr(a, cfnptr ,__LINE__))     /*ahd */
  185. #define newstr(a)                (strpool(a, cfnptr ,__LINE__))
  186. #ifdef SAFEFREE
  187. #define free(a)                  (safefree(a, cfnptr ,__LINE__))
  188. #endif
  189.  
  190. #define nil(type)               ((type *)NULL)
  191.  
  192. /*--------------------------------------------------------------------*/
  193. /*                     Configuration table layout                     */
  194. /*--------------------------------------------------------------------*/
  195.  
  196. typedef struct ConfigTable {
  197.    char *sym;
  198.    char **loc;
  199.    CONFIGBITS bits;
  200. } CONFIGTABLE;
  201.  
  202. /*--------------------------------------------------------------------*/
  203. /*                    Boolean options table layout                    */
  204. /*--------------------------------------------------------------------*/
  205.  
  206. typedef struct FlagTable {
  207.    char *sym;
  208.    int position;
  209.    CONFIGBITS bits;
  210. } FLAGTABLE;
  211.  
  212. /*--------------------------------------------------------------------*/
  213. /*                            linked list                             */
  214. /*--------------------------------------------------------------------*/
  215.  
  216. struct file_queue {
  217.    char name[FILENAME_MAX];
  218.    struct file_queue *next_link;
  219. } ;
  220.  
  221. /*--------------------------------------------------------------------*/
  222. /*                          Global variables                          */
  223. /*--------------------------------------------------------------------*/
  224.  
  225. extern int debuglevel;
  226. extern FILE *logfile;
  227. extern boolean bflag[F_LAST];
  228.  
  229. extern FLAGTABLE configFlags[];
  230.  
  231. /*--------------------------------------------------------------------*/
  232. /*                        Function prototypes                         */
  233. /*--------------------------------------------------------------------*/
  234.  
  235. void prterror(const size_t lineno, const char *fname, const char *prefix);
  236.  
  237. extern void checkptr(const void *block, const char *file, const int line);
  238.  
  239. extern int MKDIR(const char *path);
  240.                               /* Make a directory              ahd */
  241.  
  242. extern int CHDIR(const char *path);
  243.                               /* Change to a directory          ahd */
  244.  
  245. int RENAME(const char *oldname, const char *newname );
  246.  
  247. extern FILE *FSOPEN(const char *name,
  248.                    const char *mode );
  249.  
  250. #define FOPEN( name, mode, ftype ) FSOPEN( name, mode ftype )
  251.                               /* Since the last two are literals,
  252.                                  we just concat them together for
  253.                                  the call                         */
  254.  
  255. extern void options(char *s,
  256.                     SYSMODE sysmode ,
  257.                     FLAGTABLE *flags,
  258.                     boolean *xflag);
  259.  
  260. int getargs(char *line,
  261.             char **flds);                                   /* ahd */
  262.  
  263. void printmsg(int level, char *fmt, ...);
  264.  
  265. boolean configure( CONFIGBITS program );
  266.  
  267. boolean getconfig(FILE *fp,
  268.                   SYSMODE sysmode,
  269.                   CONFIGBITS program,
  270.                   CONFIGTABLE *table,
  271.                   FLAGTABLE *btable);
  272.  
  273. boolean processconfig(char *buff,
  274.                   SYSMODE sysmode,
  275.                   CONFIGBITS program,
  276.                   CONFIGTABLE *table,
  277.                   FLAGTABLE *btable);
  278.  
  279. void bugout( const size_t lineno, const char *fname);
  280.  
  281. char *strpool( const char *input , const char *file, size_t line);
  282.  
  283. void safefree( void *input , const char *file, size_t line);
  284.  
  285. char *normalize( const char *path );
  286.  
  287. #define denormalize( path ) { char *xxp = path; \
  288.    while ((xxp = strchr(xxp,'/')) != NULL)  \
  289.       *xxp++ = '\\';  }
  290.  
  291. #ifdef __GNUC__
  292. char *strlwr( char *s );
  293. #endif
  294.  
  295. /*--------------------------------------------------------------------*/
  296. /*                   Compiler specific information                    */
  297. /*--------------------------------------------------------------------*/
  298.  
  299. #if defined(__CORE__)
  300. extern   char *copyright;
  301. extern   char *copywrong;
  302. extern   long *lowcore;
  303. #endif   /* defined(__CORE__)   */
  304.  
  305. /*--------------------------------------------------------------------*/
  306. /*     This triggers a "nice" break into the debugger under BC++      */
  307. /*--------------------------------------------------------------------*/
  308.  
  309. #ifdef __TURBOC__
  310. #define BREAKPOINT   _asm INT 3
  311. #endif
  312.  
  313. #endif   /* ifndef __LIB */
  314.